package com.ruoyi.deeplearn.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.deeplearn.domain.DeepTrainTest;
import com.ruoyi.deeplearn.service.IDeepTrainTestService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 训练测试数据集Controller
 *
 * @author rww
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/deeplearn/traintest")
public class DeepTrainTestController extends BaseController
{
    @Autowired
    private IDeepTrainTestService deepTrainTestService;

    /**
     * 查询训练测试数据集列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:traintest:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepTrainTest deepTrainTest)
    {
        startPage();
        List<DeepTrainTest> list = deepTrainTestService.selectDeepTrainTestList(deepTrainTest);
        return getDataTable(list);
    }

    /**
     * 导出训练测试数据集列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:traintest:export')")
    @Log(title = "训练测试数据集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepTrainTest deepTrainTest)
    {
        List<DeepTrainTest> list = deepTrainTestService.selectDeepTrainTestList(deepTrainTest);
        ExcelUtil<DeepTrainTest> util = new ExcelUtil<DeepTrainTest>(DeepTrainTest.class);
        util.exportExcel(response, list, "训练测试数据集数据");
    }

    /**
     * 获取训练测试数据集详细信息
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:traintest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(deepTrainTestService.selectDeepTrainTestById(id));
    }

    /**
     * 新增训练测试数据集
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:traintest:add')")
    @Log(title = "训练测试数据集", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepTrainTest deepTrainTest)
    {
        return toAjax(deepTrainTestService.insertDeepTrainTest(deepTrainTest));
    }

    /**
     * 修改训练测试数据集
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:traintest:edit')")
    @Log(title = "训练测试数据集", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepTrainTest deepTrainTest)
    {
        return toAjax(deepTrainTestService.updateDeepTrainTest(deepTrainTest));
    }

    /**
     * 删除训练测试数据集
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:traintest:remove')")
    @Log(title = "训练测试数据集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deepTrainTestService.deleteDeepTrainTestByIds(ids));
    }
}
